package com.broada.apm.swagger;

import java.util.HashSet;
import java.util.Set;

import javax.ws.rs.core.Application;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;

@javax.ws.rs.ApplicationPath("/api")
public class ApplicationConfig extends Application {
    @Override
    public Set<Class<?>> getClasses() {
        Set<Class<?>> resources = new java.util.HashSet<>();
        resources.add(com.wordnik.swagger.jaxrs.listing.ResourceListingProvider.class);
        resources.add(com.wordnik.swagger.jaxrs.listing.ApiListingResource.class);
        resources.add(com.wordnik.swagger.jaxrs.listing.ApiDeclarationProvider.class);
        resources.add(com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON.class);
        resources.add(com.wordnik.swagger.jaxrs.listing.ApiDeclarationProvider.class);
        addRestResourceClasses(resources);
        return resources;
    }

    /**
     * Do not modify addRestResourceClasses() method.
     * It is automatically populated with
     * all resources defined in the project.
     * If required, comment out calling this method in getClasses().
     */
    private void addRestResourceClasses(Set<Class<?>> resources) {
        resources.add(com.broada.apm.service.AlarmService.class);
        resources.add(com.broada.apm.service.AnalyzerService.class);
        resources.add(com.broada.apm.service.ApplicationService.class);
        resources.add(com.broada.apm.service.AuthenticationService.class);
        resources.add(com.broada.apm.service.ConfigService.class);
        resources.add(com.broada.apm.service.IndicatorService.class);
        resources.add(com.broada.apm.service.KeyTradeService.class);
        resources.add(com.broada.apm.service.ReportService.class);
        resources.add(com.broada.apm.service.ResourceService.class);
        resources.add(com.broada.apm.service.ServerService.class);
        resources.add(com.broada.apm.service.SystemService.class);
        resources.add(com.broada.apm.service.TransactionService.class);
        resources.add(com.broada.apm.service.TransactionService.class);
        resources.add(com.broada.apm.service.V1PerformanceService.class);
        resources.add(com.broada.apm.service.PerformanceService.class);
        resources.add(com.broada.apm.service.ProtocalService.class);
    }
    
    @Override
    public Set<Object> getSingletons() {
        Set<Object> s = new HashSet<>();
        ObjectMapper mapper = new ObjectMapper();
        JaxbAnnotationModule module = new JaxbAnnotationModule();
        
        mapper.registerModule(module);
        JacksonJaxbJsonProvider jaxbProvider = new JacksonJaxbJsonProvider();
        jaxbProvider.setMapper(mapper);

        s.add(jaxbProvider);
        return s;
    }

}
